import { Body, Controller, Get, Param, Post } from '@nestjs/common';
import { ChatService } from './chat.service';
import { ApiOperation } from '@nestjs/swagger';

@Controller('chat')
export class ChatController {
  constructor(private readonly chatService: ChatService) {}

  @Post('model')
  @ApiOperation({
    summary: '广告合规审核对话大模型',
    description: '审核广告文本',
  })
  chatModel(@Body() body) {
    return this.chatService.chatModel(body.question);
  }

  // 保存聊天记录
  @Post('save')
  async saveChat(
    @Body('senderId') senderId: number,
    @Body('receiverId') receiverId: number,
    @Body('message') message: string,
    @Body('links') links: any,
  ): Promise<any> {
    return this.chatService.saveChat(senderId, receiverId, message, links);
  }

  // 查询聊天记录
  @Get(':userId/history/:targetUserId')
  async getChatHistory(
    @Param('userId') userId: number,
    @Param('targetUserId') targetUserId: number,
  ) {
    return this.chatService.getChatHistory(userId, targetUserId);
  }
}
